package event;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class ActionEventEx1 implements ActionListener {
	JButton btn1 = new JButton("North");
	JButton btn2 = new JButton("East");
	JButton btn3 = new JButton("Center");
	JButton btn4 = new JButton("South");
	JButton btn5 = new JButton("West");
	
	public ActionEventEx1(){
		JFrame f = new JFrame("Event Text_1");
		f.setBounds(150, 150, 300, 300);
		btn1.setBounds(10, 10, 100, 100);		
		//f.setLayout(null);
		
		f.add(btn1,"North");
		f.add(btn2,"East");
		f.add(btn3,"Center");
		f.add(btn4,"South");
		f.add(btn5,"West");
		f.setVisible(true);
		//JPanel p = new JPanel();
		
		btn1.addActionListener(this);
		btn2.addActionListener(this);
		btn3.addActionListener(this);
		btn4.addActionListener(this);
		btn5.addActionListener(this);
		
		
		
		
	}
	
	public static void main(String[] args) {
		new ActionEventEx1();

	}
	
	@Override
	public void actionPerformed(ActionEvent ev) {
		JButton obj = (JButton)ev.getSource();
		if(ev.getSource()==btn1){
			System.out.println("North Clicked");
		}else if (ev.getSource()==btn2){
			System.out.println("East Clicked");
		}else if (ev.getSource()==btn3){
			System.out.println("Center Clicked");
		}else if (ev.getSource()==btn4){
			System.out.println("South Clicked");
		}else{
			System.out.println("West Clicked");
		}
		
		System.out.println(obj.getText() + " Button Clicked");

	}
}
